#!/usr/bin/env python
# -*- encoding: UTF-8 -*-
from __future__ import print_function

from flask import url_for,request
from flask_restful import Resource

from . import api
from . import Nao
from . import db
from .. import myprint
from . import flag


@api.resource("/api/create_virtual_nao")
class create_virtual_nao(Resource):
    def get(self):
        if "name" in request.values and "port" in request.values:
            name = request.values["name"]
            port = request.values["port"]
            name = str(name)
            port = int(port)
            if name not in Nao.get_names():
                nao = Nao(name,"127.0.0.1",port)
                db.session.add(nao)